package com.shihb.behavioralpatterns.commandpattern;/**
 *Description:命令模式
 *Version:1.0.0
 *@author shihb
 *@date 2020/4/21 11:23
 */
public class Client {

  public static void main(String[] args) {
    Light light = new Light();
    LightOffCommand lightOffCommand = new LightOffCommand(light);
    LightOnCommand lightOnCommand = new LightOnCommand(light);
    Invoker invoker = new Invoker();
    invoker.setCommand(0,lightOnCommand,lightOffCommand);
    System.out.println("=====开灯=======");
    invoker.executeOnCommand(0);
    System.out.println("=====关灯=======");
    invoker.executeOffCommand(0);
    System.out.println("=====取消关灯=======");
    invoker.cancelCommand();
  }
}
